<template>
  <div class="index listDet">
    <Header></Header>
    <div class="main" style="min-height: 100%;padding-top: 60px">
      <p class="current-nav">
        当前位置 :
        <router-link to="homePage">首页</router-link>
        <i>></i>{{name}}
      </p>
      <div class="listDetMain" style="height: 100%">
        <div class="clearfix">
          <el-button class="btn" style="margin-top: 20px"  @click.stop="back"><i class="el-icon-back"> 返回</i></el-button>
        </div>
        <div class="clearfix" v-if="type==2">
          <span class="fr downBtn" @click="downloadmsg"><i class="el-icon-download"> 下载</i></span>
        </div>
         <div class="article">
          <h2 v-if="type==3">{{content.name}}</h2>
          <h2 v-else>{{content.title}}</h2>
          <h5 v-if="type==0||type==3">发布日期：{{content.publishTime | timeBy}}</h5>
          <h5 v-if="type==1||type==2">发布日期：{{content.createTime | timeBy}}</h5>
          <p v-if="type==3" v-html='content.description'></p>
          <p v-else v-html='content.content'></p>
           <h5 >
             <iframe v-if="content.fileJson&&type!=2" :src="content.fileJson" style="height: 800px;width: 100%;border: 0"></iframe>
           </h5>
        </div>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
  import config from "../../config.js";
  import Header from '../common/header3'
  import Footer from '../common/footer'

  export default {
    data() {
      return {
        content: {},
        url: '',
        type: "",
        name:'',
        name1:''
      }
    },
    components: {
      Header,
      Footer
    },
    mounted() {
      this.type = this.$route.query.type
      if (this.type == 0) {
        this.url = 'emergency/v1.0/index/news/info/'
        this.name='应急资讯'
        this.name1='时事新闻'
      } else if (this.type == 1) {
        this.url = 'emergency/v1.0/index/plan/specials/info/'
        this.name='应急预案评审与备案'
      } else if (this.type == 2) {
        this.url = 'emergency/v1.0/index/emergency/cards/info/'
        this.name='下载专题'
        this.name1='应急处置卡'
      } else if(this.type == 3){
        this.url = '/emergency/v1.0/infomation/info/'
        this.name='习近平总书记关于应急管理的重要论述'
      }else{
        this.url = '/emergency/v1.0/index/knowledge/info/'
        this.name='应急知识科普'
      }
      this.getDetail()

    },
    methods: {
      back(){
        this.$router.go(-1)
      },
      getDetail() {
        this.$axios.get(config.baseUrl + this.url + this.$route.query.id, {}).then((res) => {
          if (res.data.meta.success) {
            this.content = res.data.data
            /*if(this.type!=2&&this.content.fileJson){
              window.open(this.content.fileJson)
            }*/
          } else {

          }

        }).catch((response) => {
          console.log(response);
        })
      },
      downloadmsg() {
        if(this.content.fileJson){
          window.open(this.content.fileJson)
        }else{
          this.$message({
            message: "无附件",
            type: "error"
          });
        }
        return false;
      },

    },
    created() {
      // this.getDetail()
    },
    filters: {
      timeBy(val) {
        if (val) {
          return val.substring(0, 10)
        }
      },
    },
  }
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang='less' scoped>
  .listDet {
    .current-nav {
      float: left;
      width: 100%;
      height: 40px;
      line-height: 40px;
      padding-left: 30px;
      color: #939393;
      font-size: 14px;
      a {
        color: #333!important;
        font-size: 14px;
      }
      i {
        margin: 0 10px;
        font-style: normal;
      }
    }
    .downBtn {
      display: inline-block;
      width: 100px;
      height: 35px;
      background: #5496ff;
      color: #fff;
      border-radius: 10px;
      text-align: center;
      line-height: 35px;
      margin-top: 30px;
      cursor: pointer;
    }
    .listDetMain {
      padding: 0 130px;
      background: #fff;
      width: calc(100% - 60px);
      margin: 40px auto 0;
      border-radius: 4px;

      .article {
        padding-top: 80px;
        padding-bottom: 40px;
        width: 65%;
        margin: 0 auto;
        h2 {
          font-size: 18px;
          font-weight: bold;
          text-align: center;
        }
        h5 {
          color: #999;
          font-size: 12px;
          text-align: center;
          margin: 20px 0 30px;
        }
        p {
          text-indent: 2em;
          line-height: 22px;

        }
      }
    }
  }

</style>
<style lang='less'>
  img{ max-width: 100%}
</style>
